/**
 * Class: FVector2
 *
 * Purpose: 
 *
 * Created: Jan 23, 2010 @ 11:06:19 PM
 * @author Ken Scott
 */
package org.openfantasia.util.math;

import org.openfantasia.util.Copyable;

public class FVector2 implements Copyable<FVector2> {

	private static final int N = 2;

	public float p[][];


	public FVector2() {
		p = new float[N][N];
	}


	public FVector2(float[][] p) {
		if (p[0].length != N) {
			throw new IllegalArgumentException("Input array must be of length " + N + ", not " + p[0].length);
		}
		this.p = Math2D.copy(p);
	}


	public FVector2(FVector2 p) {
		this(p.p);
	}


	public FVector2 copy() {
		return new FVector2(p);
	}

	public void copy(FVector2 that) {
		p = Math2D.copy(that.p);
	}


	public FVector2 clear() {
		Math2D.fill(p, 0f);
		return this;
	}


	public float[][] getValue() {
		return p;
	}


	public FVector2 neg() {
		p = Math2D.neg(p);
		return this;
	}


	public FVector2 abs() {
		p = Math2D.abs(p);
		return this;
	}


	public FVector2 add(FVector2 a) {
		if(a == null) {
			return this;
		}

		p = Math2D.add(p, a.p);
		return this;
	}


	public FVector2 sub(FVector2 a) {
		if(a == null) {
			return this;
		}

		p = Math2D.sub(p, a.p);
		return this;
	}


	public FVector2 mul(FVector2 a) {
		if(a == null) {
			return this;
		}

		p = Math2D.mul(p, a.p);
		return this;
	}


	public FVector2 div(FVector2 a) {
		if(a == null) {
			return this;
		}

		p = Math2D.div(p, a.p);
		return this;
	}
}